//
//  HQYHomeFoodView.m
//  Go
//
//  Created by rimi on 16/7/7.
//  Copyright © 2016年 黄秋燕. All rights reserved.
//

#import "HQYHomeFoodView.h"
#import "HQYHomePageViewController.h"
#import "HQYHomeRecommendDetailViewController.h"

@interface HQYHomeFoodView ()
@property (nonatomic, strong) NSDictionary *dict; /**< plist文件数据字典 */
@property (nonatomic, strong) HQYHomeRecommendDetailViewController *detailVC; /**< 二级页面 */
@end

@implementation HQYHomeFoodView
- (void)drawRect:(CGRect)rect{
    //获得文件路径(需要转换的plist文件)
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"HQYHomeSelectShop.plist" ofType:nil];
    //将文件转换为数组
    _dict = [NSDictionary dictionaryWithContentsOfFile:filePath];
}


#pragma mark - 更多按钮监听
- (IBAction)clickedMoreButton:(UIButton *)sender {
    // 直接切换标签控制器
    [HQYHomePageViewController shareHomeVc].tabBarController.selectedIndex = 0;
}

#pragma mark - 蛋糕按钮监听
- (IBAction)clickedCakeBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"蛋糕"] VcTitle:@"蛋糕"];
}

#pragma mark - 小吃按钮监听
- (IBAction)clickedSnackBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"小吃"] VcTitle:@"小吃"];
    
}

#pragma mark - 火锅按钮监听
- (IBAction)clickedHotPotBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"火锅"] VcTitle:@"火锅"];
}

#pragma mark - 自助餐按钮监听
- (IBAction)clickedBuffetBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"自助餐"] VcTitle:@"自助餐"];
}

// 按钮公共点击方法，跳转二级页面
- (void)publicButtonMethodWithDict:(NSDictionary *)dict
                           VcTitle:(NSString *)title {
    self.detailVC = [[HQYHomeRecommendDetailViewController alloc] init];
    self.detailVC.shopsDict = dict;
    self.detailVC.title = title;
    [((UIViewController *)self.nextResponder.nextResponder.nextResponder).navigationController pushViewController:self.detailVC animated:YES];
}

@end
